/**
 * NearShop
 * BannerAction.java
 * com.android.nearshop.io.protocol.in
 * 
 */
package com.android.nearshop.io.protocol.in;

import com.android.nearshop.io.protocol.out.AdvList;

import android.util.Log;

/*********************************************************
 * @author : zhaohua
 * @version : 2012-8-11
 * @see : 获取广告信息。
 * @Copyright : copyrights reserved by personal 2007-2012
 **********************************************************/
public class BannerAction extends SoapAction<AdvList>
{
    public static enum ADV_TYPE
    {
        /** 二级页面及详情*/
        SUB,
        /** 首页横幅广告*/
        MAIN,
        /** 启动页面*/
        START,
        /** 不显示*/
        NONE
    }
       
    /**
     * 获取广告信息。
     * @param type 
     */
    public BannerAction(ADV_TYPE type)
    {
        super(ACTION_TYPE.ACTION_SYSTEM,"getBanner");
        addJsonParam("advType", type.ordinal()+"");
    }
    
    /**
     * @param advId 广告Id
     */
    public void setAdvId(int advId)
    {
        addJsonParam("advId", advId+"");
    }
    
    /**
     * 需显示的广告数量,此数需大于或等于1；如果为空，则查询所有。
     * @param advNum
     */
    public void setAdvNum(int advNum)
    {
        addJsonParam("advNum", advNum+"");
    }
    
    /* (non-Javadoc)
     * @see com.android.nearshop.io.protocol.in.SoapAction#parseJson(java.lang.String)
     */
    @Override
    protected AdvList parseJson(String response) throws Exception
    {
        Log.d(getMethod(), getMethod() + "response: \n " + response);
        AdvList res = new AdvList();
        res.parseData(response);
        return res;
    }

}
